package com.qys.livesMall.event.listener;

import com.qys.livesMall.financial.event.OfflineFinishEvent;
import com.qys.livesMall.financial.model.dto.app.OfflineFinishRewardDTO;
import com.qys.livesMall.financial.service.FinancialOfflineUserService;
import lombok.RequiredArgsConstructor;
import org.springframework.context.event.EventListener;
import org.springframework.core.annotation.Order;
import org.springframework.scheduling.annotation.Async;

/**
 * Created by IntelliJ IDEA.
 * User: dp
 * Date: 2023/06/10
 * Time: 15:49
 * DESCRIPTION: 用户线下理财奖励
 */
@RequiredArgsConstructor
public class OfflineFinishRewardListener {

    private final FinancialOfflineUserService offlineUserService;

    @Async
    @Order
    @EventListener(OfflineFinishEvent.class)
    public void computeUserFinancialOfflineBalance(OfflineFinishEvent event) {
        OfflineFinishRewardDTO dto = (OfflineFinishRewardDTO) event.getSource();
        offlineUserService.addUserParentBalance(dto);
    }
}
